/**
 * Created by Administrator on 2017/4/5.
 */
define('time'[
    'avalon',
    'text!../../lib/time/time.html',
    'css!../../lib/time/time.css'    
    ],function (avalon,html,css) {
    var vm
    avalon.component('tsy:time',{
        $template: html,
        id:"time",

        $init:function (vm, el) {
            vm=this
            window[vm.id]=vm
            vm.data()
        },

        $ready:function(vm, el){

        },

        onInit: function () {

        },
        data:function time(){
            var date = new Date();//获取当前日期
            var week;//获取星期
            switch (date.getDay()){
                case 1: week="星期一"; break;
                case 2: week="星期二"; break;
                case 3: week="星期三"; break;
                case 4: week="星期四"; break;
                case 5: week="星期五"; break;
                case 6: week="星期六"; break;
                default:week="星期天"; break;
            }
            var month;  //获取月份
            switch (date.getMonth()+1){
                case 1: month="January"; break;
                case 2: month="february "; break;
                case 3: month="March "; break;
                case 4: month="April "; break;
                case 5: month="May "; break;
                case 6: month="June "; break;
                case 7: month="July "; break;
                case 8: month="August"; break;
                case 9: month="September"; break;
                case 10: month="October "; break;
                case 11: month="November"; break;
                case 12: month="December"; break;
            }
            var year = date.getFullYear();//获取年份
            var day = date.getDate();//获取当天的日
            if(day<10)
                day= "0"+day;
            var hours =date.getHours();//获取小时
            if(hours<10)
                hours= "0"+hours;
            var minutes =date.getMinutes();//获取分
            if(minutes<10)
                minutes= "0"+minutes;
            var seconds=date.getSeconds();//获取秒
            if(seconds<10)
                seconds= "0"+seconds;
            var tian =day+" "+month+" "+week;
            var shi=hours+":"+minutes+":"+seconds;
            document.getElementById("nian").innerHTML= year;
            document.getElementById("tian").innerHTML= tian;
            document.getElementById("shi").innerHTML= shi;
            //设置1秒调用一次函数
            setInterval("vm.data()",100);
        }

     
        
        
    })
})